package com.yugao.fintech.antelope.pay.common.manager;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yugao.fintech.antelope.pay.common.mapper.TradeDataMapper;
import com.yugao.fintech.antelope.pay.model.entity.TradeData;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;


@Component
public class TradeDataManager extends ServiceImpl<TradeDataMapper, TradeData> {

    public void saveTradeData(TradeData req) {
        String tradeContent = req.getTradeContent();
        if (StringUtils.isNotEmpty(tradeContent)) {
            LambdaQueryWrapper<TradeData> lqw = TradeData.lqw()
                    .eq(StringUtils.isNotEmpty(req.getMchOrderNo()), TradeData::getMchOrderNo, req.getMchOrderNo())
                    .eq(StringUtils.isNotEmpty(req.getPayOrderNo()), TradeData::getPayOrderNo, req.getPayOrderNo());
            this.saveOrUpdate(req, lqw);
        }
    }
}
